// pages/distribution/invite.js
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },
    bindInput(evt){
        let value = evt.detail.value
        this.setData({
            invite_code:value
        })
    },
    joinSubmit(evt){
        let value = evt.detail.value.invite_code
        if(!value){
            this.setData({
                invite_code:''
            })
            return
        }
        wx.showLoading({
            title: '加载中...',
        })
        app.http.post('distributor/code-join',{
            data:{
                invite_code:value
            }
        }).then(res=>{
            wx.hideLoading()
            if(res.data.status==1){
                wx.showToast({
                    icon:'none',
                    title: '申请成功',
                })
                wx.navigateBack({ })
            }else{
                wx.showModal({
                    title: '温馨提示',
                    content: res.data.msg,
                    showCancel:false,
                    confirmColor:'#ff5400'
                })
            }
        })
    },
    
})